<?php
/* -------------------------------------------------------------------
 * Database Helper
 * -------------------------------------------------------------------
 * This file is create for storing name of table, and field.
 * 
 */

if(!function_exists('table'))
{
  function table($key)
  {
    // Tables' name
    $table['ads']           = 'tbl_ads';
    $table['tbnswer']        = 'tbl_answer';
    $table['banner']        = 'tbl_banner';
    $table['bannerZone']    = 'tbl_banner_zone';
    $table['borrowComment'] = 'tbl_ads';
    $table['category']      = 'tbl_category';
    $table['class']         = 'tbl_class';
    $table['location']      = 'tbl_location';
    $table['role']          = 'tbl_role';
    $table['shop']          = 'tbl_shop';
    $table['subject']       = 'tbl_subject';
    $table['token']         = 'tbl_token';
    $table['type']          = 'tbl_type';
    $table['user']          = 'tbl_user';
    $table['image']         = 'tbl_image';

    if(array_key_exists($key, $table)) {
      return $table[$key];
    }

    return NULL;
  }
}

if(!function_exists('field'))
{
  function field($key)
  {

    // Fields' name
    $field['answer']            = 'answer';
    $field['adsId']             = 'ads_id';
    $field['categoryId']        = 'category_id';
    $field['createdAt']         = 'created_at';
    $field['classId']           = 'class_id';
    $field['deletedAt']         = 'deleted_at';
    $field['description']       = 'description';
    $field['email']             = 'email';
    $field['fname']             = 'fname';
    $field['flag']              = 'flag';
    $field['id']                = 'id';
    $field['image']             = 'image';
    $field['isDefault']         = 'is_default';
    $field['isDisable']         = 'is_disable';
    $field['isVerify']          = 'is_verify';
    $field['lname']             = 'lname';
    $field['locationId']        = 'location_id';
    $field['name']              = 'name';
    $field['order']             = 'order';
    $field['parentId']          = 'parent_id';
    $field['password']          = 'password';
    $field['phone']             = 'phone';
    $field['price']             = 'price';
    $field['publishedAt']       = 'published_at';
    $field['question']          = 'question';
    $field['roleId']            = 'role_id';
    $field['shortDescription']  = 'short_description';
    $field['title']             = 'title';
    $field['token']             = 'token';
    $field['typeId']            = 'type_id';
    $field['updatedAt']         = 'updated_at';
    $field['url']               = 'url';
    $field['userId']            = 'user_id';
    $field['username']          = 'username';
    $field['zoneId']            = 'zone_id';
    $field['questionId']       = 'question_id';

    // Alias
    $field['parent']    = 'parent';
    $field['category']  = 'category';
    $field['location']  = 'location';
    $field['type']    = 'type';
    $field['user']    = 'user';
    $field['zone']    = 'zone';
    $field['roleName']  = 'role_name';

    if(array_key_exists($key, $field))
    {
      return $field[$key];
    }

    return NULL;
  }
}